from docx import Document


def remove_blank_lines(word_file):
    with Document(word_file) as doc:
        paragraphs = [para for para in doc.paragraphs if para.text.strip()]
        doc.paragraphs.clear()
        doc.paragraphs.extend(paragraphs)
        doc.save('processed_' + word_file)


word_file = 'new_中级1.docx'  # 替换为你的Word文件路径
remove_blank_lines(word_file)